package jgl.vajra.kingkong.part.vehicle.viewModel;

import java.util.List;

import jgl.vajra.kingkong.bean.CommonAddressBean;
import jgl.vajra.kingkong.part.vehicle.contract.CommonAddressContract;
import jgl.vajra.kingkong.part.vehicle.model.CommonAddressModel;
import jgl.vajra.kingkong.widget.mvvm.factory.CreateModel;
import jgl.vajra.kingkong.widget.retrofithelper.rxsubscriber.ProgressObserver;

@CreateModel(CommonAddressModel.class)
public class CommonAddressViewModel extends CommonAddressContract.ViewModel{
    @Override
    public void getAddressList(String authorization) {
        mModel.getAddressList(authorization).subscribe(new ProgressObserver<List<CommonAddressBean>>(true,this) {
            @Override
            public void _onNext(List<CommonAddressBean> data) {
                mView.returnAddressListData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);

            }
        });
    }

    @Override
    public void deleteAddress(String authorization, long id) {
        mModel.deleteAddress(authorization,id).subscribe(new ProgressObserver<String>(true,this) {
            @Override
            public void _onNext(String data) {
                mView.returnDeleteAddress();
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);

            }
        });
    }
}
